package com.briup.smartcity_group7.service.impl;


import com.briup.smartcity_group7.bean.basic.Comment;
import com.briup.smartcity_group7.dao.basic.CommentMapper;
import com.briup.smartcity_group7.dao.ext.CommentExtMapper;
import com.briup.smartcity_group7.service.ICommentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommentServiceImpl implements ICommentService {
    @Autowired
    private CommentMapper mapper;
    @Autowired
    private CommentExtMapper extMapper;

    @Override
    public void checkComment(int id, int status) {
        extMapper.updateStatus(id,status);
    }

    @Override
    public PageInfo<Comment> pageQuery(int pageNum, int pageSize, String keywords) {
        return PageHelper.startPage(pageNum,pageSize).doSelectPageInfo(()->extMapper.findByPage(keywords));
    }

    @Override
    public void deleteById(int id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void batchDelete(int[] ids) {
        for(int id:ids){
            mapper.deleteByPrimaryKey(id);
        }
    }
}
